package com.mcms.web.control;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import com.mcms.service.UserService;
import com.mcms.web.LoginCommand;

/**
 * 预约管理
 * (就诊预约/回访预约)
 * @author 
 */
public class AppointmentManager extends AbstractCommandController {
	private UserService userService;

	public AppointmentManager() {
		setCommandClass(LoginCommand.class);
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	protected ModelAndView handle(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		
		System.out.println("Begin:AppointmentManager ");
		/**参数获取*/
		String actionType = request.getParameter("actionType");// 控制跳转参数
		String userName = request.getParameter("userName");
		String deptCode = request.getParameter("deptCode");
		
		System.out.println("at:"+actionType+";un:"+userName+";deptCode="+deptCode);
		
		/**登陆页跳转*/
		if( actionType!=null && actionType.trim().length()>0 ){
			if(actionType.equalsIgnoreCase("yyjz")){// 预约就诊
				return new ModelAndView("custom/doctor_appointment"); 
			}
			else if(actionType.equalsIgnoreCase("appointmentDoctorList")){// 展示预约就诊提醒列表
				if(deptCode.equalsIgnoreCase("sc")||deptCode.equalsIgnoreCase("dw")){// 电网部和市场部的客户信息更新页面跳转
					return new ModelAndView("custom/qddepart/doctorAppointmentAlertList"); 
				}else if(deptCode.equalsIgnoreCase("xs")){// 分诊台的客户信息更新页面跳转
					return new ModelAndView("custom/xsdepart/doctorAppointmentAlertList"); 
				}else if(deptCode.equalsIgnoreCase("kf")){// 分诊台的客户信息更新页面跳转
					return new ModelAndView("custom/kfdepart/doctorAppointmentAlertList"); 
				}
			}
			else if(actionType.equalsIgnoreCase("doctorAppointmentUpdate")){// 修改预约就诊时间
				if(deptCode.equalsIgnoreCase("sc")||deptCode.equalsIgnoreCase("dw")){// 电网部和市场部的客户信息更新页面跳转
					return new ModelAndView("custom/qddepart/doctorAppointmentUpdate"); 
				}else if(deptCode.equalsIgnoreCase("xs")){// 分诊台的客户信息更新页面跳转
					return new ModelAndView("custom/xsdepart/doctorAppointmentUpdate"); 
				}else if(deptCode.equalsIgnoreCase("kf")){// 分诊台的客户信息更新页面跳转
					return new ModelAndView("custom/kfdepart/doctorAppointmentUpdate"); 
				}
				
			}else if(actionType.equals("updateCustomPage")){// 客户信息更新页面跳转
				
				if(deptCode.equalsIgnoreCase("sc")||deptCode.equalsIgnoreCase("dw")){// 电网部和市场部的客户信息更新页面跳转
					
					return new ModelAndView("custom/qddepart/updateCustom_qd"); 
				}else if(deptCode.equalsIgnoreCase("fz")){// 分诊台的客户信息更新页面跳转
					return new ModelAndView("custom/updateCustom_xc"); 
				}
			}
		}
		
		
		
		/**默认跳转至登陆页面*/
		return new ModelAndView("login");

	}
}
